<%@ page import="BusinessLogic.ControllerFacade" %>
<%@ page import="Presentation.WebUI.LinksGenerator" %>
<%@ page import="java.util.Collection" %>
<%@ page errorPage="error.jsp" %>

<%
	ControllerFacade c = (ControllerFacade)session.getAttribute("c");

    int amount = c.getListLength();
    int start = 0;
    String startParam = request.getParameter("start");
    if (startParam != null)
        start = Integer.parseInt(startParam);
%>

<h2>Search movies</h2>

<%
    String movieName = request.getParameter("movieName");
    int rank = Integer.parseInt(request.getParameter("rank"));
    String[] list = c.getUsersByMovieRating(movieName, rank,start);

    out.println("<h3>Showing users who ranked " + movieName + " at least " + rank + " </h3>");
    
    String[] show = new String[list.length];
    for (int i=0; i<list.length; i++)
        show[i] = LinksGenerator.userLink(list[i]);

    String last = "<br />No More Users<br /><br />";
    out.println(LinksGenerator.showListWithNavButtons(show, request.getParameterMap(), start, amount, last));

%>
